# Contributor: Konstantin Kulikov <k.kulikov2@gmail.com>
# Maintainer: Konstantin Kulikov <k.kulikov2@gmail.com>
pkgname=mtg
pkgver=1.0.6
pkgrel=0
pkgdesc="MTPROTO proxy for Telegram"
url="https://github.com/9seconds/mtg"
arch="all !mips !mips64"
license="MIT"
makedepends="go"
options="!check chmod-clean net" # No test suite.
subpackages="$pkgname-openrc"
install="mtg.pre-install"
source="go.mod go.sum apk.go mtg.initd mtg.confd"
builddir=$srcdir

export GOPATH=${GOPATH:-$srcdir/go}
export GOCACHE=${GOCACHE:-$srcdir/go-build}
export GOTMPDIR=${GOTMPDIR:-$srcdir}

build() {
	for pkg in $(go list -f '{{ join .Imports " " }}'); do
		go build -mod=readonly -v $pkg
	done
}

package() {
	install -Dm755 $builddir/mtg $pkgdir/usr/sbin/mtg
	install -Dm755 $srcdir/$pkgname.initd $pkgdir/etc/init.d/$pkgname
	install -Dm644 $srcdir/$pkgname.confd $pkgdir/etc/conf.d/$pkgname
}

sha512sums="9e10cf646191c4060d1708277c8ea730f3eb2da56f546b6abe7b9b29bc64a250520b403e5a81c62436932e29221e0e4551dfb1df6ee5140d9644e2cf684feeb2  go.mod
b2c7496a013a5066db63738333f62be3873d9be6f121001854784b28d8e1ae3b78711b1a2e2e5b7563008e3889a5970a46be4ce7717690d3de9a4101b910a5cc  go.sum
2b4104c4fd669eadf876fb6858de395083f3b3534bc67fdb931cb22a112d939df2eeb8727dd350d6f40dcf173d0f7e36f7ccf43d074b8fa7efd0c190388acc45  apk.go
39d7bf9eda457435f58ab0415f211d465e1643d357d40d67dc86a609bb0467acd4aef75e50b6b753bb687f6209f29fd426cb283af3743852e9c385b09d4033b4  mtg.initd
2988b98d27ad1ecc954f5c34e3ebd3f40fd42d1429c60eccf82d3b19e326bf0f6c17670e5800f1bdfcf93cc6a9c4ef6d39bf4561d07abdf0bc5c9d091bda20e9  mtg.confd"
